﻿Imports System.Net.Mail

Partial Class Contactenos
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Master.MostrarClienteSession()
    End Sub


    Protected Sub btnEnviarMail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEnviarMail.Click
        Try
            If txtHotmail.Text = "" Then
                MsgBox("Error! No hay usuario")
            Else
                If txtPasswordE.Text = "" Then
                    MsgBox("Error! No Password")
                Else
                    Dim message As New Net.Mail.MailMessage(txtHotmail.Text, txtDestinatario.Text, txtAsunto.Text, rtxtMensaje.Text)
                    'aca vamos a necesitar el webserver del e-mail. En este caso usaremos Hotmail. 
                    'Servidor SMtP de Hotmail: smtp.live.com, Puerto de hotmail= 587 ?
                    Dim smtp As New Net.Mail.SmtpClient("smtp.live.com", 587)
                    Dim credential As New Net.NetworkCredential(txtHotmail.Text, txtPasswordE.Text) 'Tu cuenta del Hotmail
                    smtp.EnableSsl = True
                    smtp.Credentials = credential
                    smtp.Port = 587
                    smtp.Host = "smtp.live.com"
                    smtp.Send(message)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        txtDestinatario.Text = ""
        txtAsunto.Text = ""
        rtxtMensaje.Text = ""
    End Sub
End Class
